package job.job_0820;

public class Hannotel {
    public static void main(String[] args) {//递归求解汉诺塔问题
        hannotel(3,'A','B','C');
    }
    public static void move(char pos1,char pos2){
        System.out.println(pos1+"->"+pos2);
    }
    public static void hannotel(int n,char pos1,char pos2,char pos3){
        if(n<2){
            move(pos1,pos3);
            return;
        }
        else {
            hannotel(n-1,pos1,pos3,pos2);
            move(pos1,pos3);
            hannotel(n-1,pos2,pos1,pos3);
        }
    }
}
